﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Krile.Kernel.Data;

namespace Krile.Forms.Dialogs.Editor
{
    public partial class QuickTab : Form
    {
        Data.TabData baseData;
        Data.TabData newData;
        public Data.TabData TabData
        {
            get
            {
                if (newData != null)
                    return newData;
                else
                    return baseData;
            }
            set
            {
                baseData = value;
                newData = null;
            }
        }
        public QuickTab()
        {
            InitializeComponent();
            newData = null;
            baseData = null;
        }

        private void OKBtn_Click(object sender, EventArgs e)
        {
            newData = new Krile.Data.TabData();
            newData.Name = String.Format(Lang.QuickTab.TabImportStr, ArgText.Text, baseData.Name);
            newData.UnNotify = baseData.UnNotify;
            List<SearchDataBase> sdbArray = new List<SearchDataBase>();
            if (baseData.ContainSearchData != null)
                sdbArray.Add(baseData.ContainSearchData);
            sdbArray.Add(new Data.TextSearchData(ArgText.Text));
            newData.ContainSearchData = new SearchDataCluster(sdbArray.ToArray());
        }

        private void ArgText_TextChanged(object sender, EventArgs e)
        {
            OKBtn.Enabled = ArgText.Text != String.Empty;
        }
    }
}
